package com.tomatozq163.sharding.service.impl;

import java.util.List;
import java.util.Map;
import java.util.UUID;
import javax.annotation.Resource;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;
import com.tomatozq163.sharding.dao.UserDAO;
import com.tomatozq163.sharding.entity.User;
import com.tomatozq163.sharding.service.UserService;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;

@Transactional
@Component(value="userService")
public class UserServiceImpl implements UserService {
	@Resource(name="userDAO")
	private UserDAO userDAO;

	@Override
	public User get(String id) {
		// TODO Auto-generated method stub
		return userDAO.get(id);
	}

	@Override
	public int insert(User model) {
		// TODO Auto-generated method stub
		//model.setId(UUID.randomUUID().toString());
		
		return userDAO.insert(model);
	}

	@Override
	public int update(User model) {
		// TODO Auto-generated method stub
		return userDAO.update(model);		
	}

	@Override
	public int delete(String id) {
		// TODO Auto-generated method stub
		return userDAO.delete(id);
	}

	@Override
	public boolean exist(String id) {
		// TODO Auto-generated method stub
		int count = userDAO.exist(id);
		
		return count > 0 ? true : false;
	}
	
	@Override
	public List<User> list() {
		// TODO Auto-generated method stub
		return userDAO.list();
	}
}